<?
 session_start();
 require("connect.php");
 require("checksessionsodaubai.php");
 if ($_REQUEST["option"]==Xoa)
	mysql_query("delete from baiviet where mabv='{$_REQUEST["mabv"]}'");	
 $chon2=$_REQUEST["option2"];
 switch ($chon2){		
		case "chapnhan":
			mysql_query("update binhluanbaiviet set trangthai='1' where mabl={$_REQUEST["mabl"]}") or die("Kiểm tra lại !");
			break;		
		case "xoa":				
			mysql_query("delete from binhluanbaiviet where mabl='{$_REQUEST["mabl"]}'");			
			break;
	}
?>
<html><!-- InstanceBegin template="/Templates/giaovientemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="scripts/innovaeditor.js"></script>
<link rel="stylesheet" type="text/css" href="css/engine.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
</script>
</head>
<body>
<table align="center" width="938" cellpadding="0" cellspacing="1" border="0">
	<tr><td colspan="3" height="26" bgcolor="#CCCCCC">		
	<? $magiaovien=$_SESSION["username"];?>	
	<!--Menu 1-->
	<div id="tool">

	<a href="index.php">Trang chủ của trường</a>
		 | 
		<a href="hotrohoctap">Hỗ trợ học tập</a>

		 | 
		 
		<a href="lienhe.php">Liên hệ</a>
	</div>
	<!--het menu 1-->
	</td></tr>
	<tr><td colspan="3" height="34" bgcolor="#CCCCCC">	
	<div id="menuwrapper">
		<ul id="p7menubar">
			 <li><a class="trigger" href="giaovien.php?magv=<? echo $magiaovien;?>" target="_self">Trang chủ</a></li>
			  <li class="linemenus"></li>					 
		 	 <li><a class="trigger" href="trangcaclop.php" target="_self">Trang các lớp</a>	
			 <li class="linemenus"></li>					 
		 	 <li><a class="trigger" href="thongtincanhangv.php?magv=<? echo $magiaovien;?>" target="_self">Thông tin cá nhân</a>						  			 
		  <!--bat dau-->
		  	<?
				if ($_SESSION["login"]==true){
			?>
			 <li class="linemenus"></li>					 					 
					 <li><a class="trigger" href="logout.php" target="_self">Thoát</a>						
					<li class="linemenus"></li>
					<li><a class="trigger" href="logout.php" target="_self">
					<?
					$resu1=mysql_query("select * from giaovien where magv='{$magiaovien}'"); 
					$row1=mysql_fetch_array($resu1);
					echo "Xin chào : ";echo $row1["hotendem"];echo "&nbsp;";echo $row1["ten"];
					?>		
					<? }?>
					</a>			
		  <!--het-->
		</ul>
	</div>	
	</td></tr>
	<tr>
		<td width="175px" height="800" valign="top">		
		<!--menu trai-->
		<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr><td valign="middle" height="30">
			<a href="quanlydiemkt.php?magv=<? echo $magiaovien;?>"><img src="anh/diemkt.png" height="16" width="16" border="0">&nbsp;</a><a href="quanlydiemkt.php?magv=<? echo $magiaovien;?>">Quản lý điểm kiểm tra</a>
		</td></tr>	
		<tr><td valign="middle" height="30">
			<a href="quanlydiemthi.php?magv=<? echo $magiaovien;?>"><img src="anh/diemthi.png" height="16" width="16" border="0">&nbsp;</a><a href="quanlydiemthi.php?magv=<? echo $magiaovien;?>">Quản lý điểm thi</a>
		</td></tr>	
		<tr><td valign="middle" height="30">
			<a href="thoikhoabieugv.php?magv=<? echo $magiaovien;?>"><img src="anh/thoikhoabieu.png" height="16" width="16" border="0">&nbsp;</a><a href="thoikhoabieugv.php?magv=<? echo $magiaovien;?>">Thời khóa biểu</a>
		</td></tr>	
		<?
			$resu=mysql_query("select * from lop where magvcn='{$magiaovien}'");
			if(mysql_num_rows($resu)>0){
		?>
		<!--Begin menu cua giao vien chu nhiem-->
		<tr><td valign="middle" height="30">
			<a href="quanlybaiviet.php?magv=<? echo $magiaovien;?>"><img src="anh/baiviet.png" height="16" width="16" border="0">&nbsp;</a>
			<a href="quanlybaiviet.php?magv=<? echo $magiaovien;?>">Quản lý bài viết</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="quanlyhocsinhgv.php?magv=<? echo $magiaovien;?>"><img src="anh/user.png" height="16" width="16" border="0">&nbsp;</a>
			<a href="quanlyhocsinhgv.php?magv=<? echo $magiaovien;?>">Quản lý học sinh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="quanlyphuhuynhgv.php?magv=<? echo $magiaovien;?>"><img src="anh/phuhuynh.png" height="16" width="16" border="0">&nbsp;</a>
			<a href="quanlyphuhuynhgv.php?magv=<? echo $magiaovien;?>">Quản lý phụ huynh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="quanlyanhgv.php?magv=<? echo $magiaovien;?>"><img src="anh/album.png" height="16" width="16" border="0">&nbsp;</a>
			<a href="quanlyanhgv.php?magv=<? echo $magiaovien;?>">Quản lý ảnh upload</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="quanlytailieugv.php?magv=<? echo $magiaovien;?>"><img src="anh/tailieuupload.png" height="16" width="16" border="0">&nbsp;</a>
			<a href="quanlytailieugv.php?magv=<? echo $magiaovien;?>">Quản lý tài liệu</a>
		</td></tr>
		<? }?>
		<!--End menu giao vien chu nhiem-->				
		</table>
		<!-- het menu trai-->
		</td>
		
    <td align="center" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->
	<?
		$magv=$_REQUEST["magv"];			
	?>
	<!--Begin ca bai viet moi-->
				<div class="gift_box_quatang">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="gift_quatang_infoblog">
						<h1 align="left"><font color="#CC3333">Các bài viết mới chưa xử lý</font></h1>
						<table align="center" cellpadding="0" cellspacing="3" border="0" width="100%">
						<?
						$result=mysql_query("select * from lop where magvcn='{$magv}'");
						while($r=mysql_fetch_array($result)){													
							$result2=mysql_query("select * from baiviet where mal='{$r["mal"]}' and trangthai='0' order by ngay DESC");
								if(mysql_num_rows($result2)>0){									
									while($r2=mysql_fetch_array($result2)){ 
						?>
											<tr><td>							
												<a href="quanlybaivietchitiet.php?mabv=<? echo $r2["mabv"];?>">
												<img src="anh/icon1.gif" width="16" height="16" border="0">&nbsp;
												<?										
														$string=$r2["tieude"];
														echo substr($string,0,70);
														if(strlen($string)>=71){
														echo "...";						
														}				
												?>
												</a>
											</td></tr>																
											<tr>
												<td class="tieude3">  bởi 																		
													<?
														$result31=mysql_query("select * from hocsinh where mahs='{$r2["nguoidang"]}'");
														if(mysql_num_rows($result31)>0){
														while($r31=mysql_fetch_array($result31)){
														?>
															<a href="thongtinhocsinhgv.php?mahs=<? echo $r2["nguoidang"];?>" title="Thông tin học sinh">																								
														<?
															echo $r31["hotendem"];
															echo "&nbsp;";
															echo $r31["ten"];
														?></a><?
														}}else {
															$result21=mysql_query("select * from giaovien where magv='{$r2["nguoidang"]}'"); 
															$r21=mysql_fetch_array($result21);
															echo "giáo viên";
															echo "&nbsp;";
															echo $r21["hotendem"];
															echo "&nbsp;";
															echo $r21["ten"];
															
														}
													?>																							
												&nbsp;vào lúc &nbsp;<? echo $r2["ngay"];?>
												&nbsp;thuộc <?
												$result4=mysql_query("select * from loaibaiviet where malbv='{$r2["malbv"]}'");
												$r4=mysql_fetch_array($result4);
												?>
												<a href="loaibaivietgv.php?malbv=<? echo $r2["malbv"];?>"><?
												echo $r4["tenlbv"];
												?></a>
												</td>										
											</tr>
											<tr>
												<td class="tieude3">
													<a href="quanlybaivietchitiet.php?mabv=<? echo $r2["mabv"];?>" title="Xem chi tiết">
													<img src="anh/chitiet.png" height="13" width="13" border="0">&nbsp;Chi tiết
													</a>&nbsp;
													<a href="?mabv=<? echo $r2["mabv"];?>&option=Xoa" title="Xóa bài viết" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
													<img src="anh/xoa.png" height="13" width="13" border="0">&nbsp;Xóa
													</a>													
												</td>
											</tr>
									
						<? 
										} //end of while(r2)
							  		} //end of if(r2>0)																	
						}//end of while(r)
						?>																				
						</table>			 
						<div class="gift_quatang_mView">
							<span style="float:left; width:90px;"> 
							
							</span>
							<span style=" float: right; width:100px" >								
			
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>
			
				</div>
				<!--End cac bai viet moi-->
				<!--Begin cac y kien moi-->
				<div class="gift_box_quatang">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="gift_quatang_infoblog">
						<h1 align="left"><font color="#CC3333">Các bình luận mới chưa xử lý</font></h1>
						<table align="center" cellpadding="0" cellspacing="3" border="0" width="100%">
						<?
						$result5=mysql_query("select * from lop where magvcn='{$magv}'");
						while($r5=mysql_fetch_array($result5)){						
							$result6=mysql_query("select * from baiviet where mal='{$r5["mal"]}'");							
							while($r6=mysql_fetch_array($result6)){
									$result7=mysql_query("select * from binhluanbaiviet where mabv='{$r6["mabv"]}' and trangthai='0'");									
										while($r7=mysql_fetch_array($result7)) {
									?>
										<tr><td>
											<img src="anh/comment.png" height="16" width="16" border="0">&nbsp;											
											<?
														$result8=mysql_query("select * from hocsinh where mahs='{$r7["nguoidang"]}'");
														if(mysql_num_rows($result8)>0){
														$r8=mysql_fetch_array($result8);
															?>
																<a href="thongtinhocsinhgv.php?mahs=<? echo $r2["nguoidang"];?>" title="Thông tin học sinh">																								
															<?
																echo $r8["hotendem"];
																echo "&nbsp;";
																echo $r8["ten"];
															?></a><?
														}else {
															$result81=mysql_query("select * from giaovien where magv='{$r7["nguoidang"]}'"); 
															$r81=mysql_fetch_array($result81);
															echo "Giáo viên";
															echo "&nbsp;";
															echo $r81["hotendem"];
															echo "&nbsp;";
															echo $r81["ten"];
															
														}
											?>																								
											vào lúc <? echo $r7["thoigian"];?>&nbsp;
											<a href="?option2=chapnhan&mabl=<? echo $r7["mabl"]?>&magv=<? echo $magv;?>"  onClick="return confirm('Bạn chấp nhận bình luận này ?');">
												<img src="anh/accept.png" height="13" width="13" border="0">&nbsp;Chấp nhận
											</a>&nbsp;
											<a href="?option2=xoa&mabl=<? echo $r7["mabl"]?>&magv=<? echo $magv;?>" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
												<img src="anh/xoa.png" height="13" width="13" border="0">&nbsp;Xóa
											</a>
										</td></tr>
										<tr><td>&nbsp;&nbsp;<? echo $r7["noidung"];?></td></tr>	
							<? }}}?>
						</table>		 
						<div class="gift_quatang_mView">
							<span style="float:left; width:90px;"> 
							
							</span>
							<span style=" float: right; width:100px" >								
			
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>
			
				</div>
				<!--End cac y kien moi-->
				
	<!-- InstanceEndEditable --></td>
	<!--menu phai-->
	<td width="175" valign="top" align="center">
		<!--Begin-->
				<div class="panelgv">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="noidungpanelgv">
						<h1 align="left">Album ảnh</h1>
						<table align="center" width="100%" cellpadding="2" cellspacing="0" border="0">
						<?
						$resu2=mysql_query("select * from albumtruong where nguoidang='{$magiaovien}' order by thoigian DESC limit 0,3");
						while($row2=mysql_fetch_array($resu2)){						
						?>	
							<tr><td class="tieude3"><a href="chitietalbumcuagiaovien.php?maalbum=<? echo $row2["maalbum"];?>">
										<img src="anh/1px.gif" height="15" width="16" border="0">
									</a>
									<a href="chitietalbumcuagiaovien.php?maalbum=<? echo $row2["maalbum"];?>">
										<?
											echo $row2["tenalbum"];
										?>
									</a>
							</td></tr>																					
						<? }?>
						<?
						$resu3=mysql_query("select * from albumlop where nguoidang='{$magiaovien}' order by thoigian DESC limit 0,3");
						while($row3=mysql_fetch_array($resu3)){						
						?>	
							<tr><td class="tieude3"><a href="chitietalbumcuagiaovien.php?maalbum=<? echo $row2["maalbum"];?>">
										<img src="anh/1px.gif" height="15" width="15" border="0">
									</a>
									<a href="chitietalbumcuagiaovien.php?maalbum=<? echo $row3["maalbum"];?>">
										<?
											echo $row3["tenalbum"];
										?>
									</a>
							</td></tr>																					
						<? }?>
						</table> 
						<div class="gift_quatang_mView">
							<span style="float:left; width:70px;">	
							<a href="tatcaalbumgv.php">
							Xem tất cả
							</a>						
							</span>
							<span style=" float: right;">														
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>			
				</div>
	</td>		
	</tr>
	<tr><td colspan="3" align="center" valign="middle" bgcolor="#999999" height="100">Phạm Đức Đóa - Khoa CNTT - Đại học Xây Dựng</td></tr>
</table>
</body>
<!-- InstanceEnd --></html>
